<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Bootstrap -->
    <link href="/static/admin/css/bootstrap.min.css" rel="stylesheet">
    <link href="/static/admin/css/adminindex.css" rel="stylesheet">
    {css href="/static/admin/css/my.css"}
    <title>Bootstrap 101 Template</title>
    <!--[if lt IE 9]>
    <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

    <nav class="navbar navbar-inverse navbar-fixed-top">
        <div class="container-fluid">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="#">淘票票</a>
            </div>
            <div id="navbar" class="navbar-collapse collapse">
                <ul class="nav navbar-nav navbar-right">
                    <li><a href="#">欢迎,{:session('name', '', 'admin')}</a></li>
                    <li><a href="#">Settings</a></li>
                    <li><a href="#">Profile</a></li>
                    <li><a href="{:url('admin/adminlogin/out')}">登出</a></li>
                </ul>
                <form class="navbar-form navbar-right">
                    <input type="text" class="form-control" placeholder="Search...">
                </form>
            </div>
        </div>
    </nav>

    <div class="container-fluid">
        <div class="row">

<!-- 左导航栏-->
{block name='nav'}
            <div class="col-sm-3 col-md-2 sidebar">
                <ul class="nav nav-sidebar lis">
                    <li role="presentation" class="user-list"><a href="{:url('admin/user/index')}">用户列表 <span class="sr-only">(current)</span></a></li>
                    <li><a href="{:url('admin/user/create')}">新增用户</a></li>
                    <li><a href="#">Analytics</a></li>
                    <li><a href="#">Export</a></li>
                </ul>
                <ul class="nav nav-sidebar filmlis">
                    <li class='filmschedule'><a href="{:url('admin/filmschedule/index')}">电影排片表</a></li>
                    <li class='filmlist' role="presentation"><a href="{:url('admin/film/index')}">上映电影</a></li>
                    <li class='filmcreate'><a href="{:url('admin/film/create')}">新增电影</a></li>
                    <li class="banner"><a href="{:url('admin/banner/add')}">轮播图管理</a></li>
                    <li><a href="">More navigation</a></li>
                </ul>
                <ul class="nav nav-sidebar">
                    <li><a href="">Nav item again</a></li>
                    <li><a href="">One more nav</a></li>
                    <li><a href="">Another nav item</a></li>
                </ul>
            </div>
{/block}
<!-- 左导航栏结束-->


            <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
               <!--  <h1 class="page-header">Dashboard</h1>

                <div class="row placeholders">
                    <div class="col-xs-6 col-sm-3 placeholder">
                        <img src="" width="200" height="200" class="img-responsive" alt="Generic placeholder thumbnail">
                        <h4>Label</h4>
                        <span class="text-muted">Something else</span>
                    </div>
                    <div class="col-xs-6 col-sm-3 placeholder">
                        <img src="" width="200" height="200" class="img-responsive" alt="Generic placeholder thumbnail">
                        <h4>Label</h4>
                        <span class="text-muted">Something else</span>
                    </div>
                    <div class="col-xs-6 col-sm-3 placeholder">
                        <img src="" width="200" height="200" class="img-responsive" alt="Generic placeholder thumbnail">
                        <h4>Label</h4>
                        <span class="text-muted">Something else</span>
                    </div>
                    <div class="col-xs-6 col-sm-3 placeholder">
                        <img src="" width="200" height="200" class="img-responsive" alt="Generic placeholder thumbnail">
                        <h4>Label</h4>
                        <span class="text-muted">Something else</span>
                    </div>
                </div> -->
{block name="main"}
<!-- 主体开始-->
                <h2 class="sub-header">用户列表</h2>

                <div class="table-responsive">
                    <table class="table table-striped table-hover">
                        <thead>
                            <tr>
                                <th>#</th>
                                <th>姓名</th>
                                <th>密码</th>
                                <th>昵称</th>
                                <th class='col-md-2'>电话号</th>
                                <th>注册时间</th>
                                <th>VIP</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                        {foreach $list as $v}
                            <tr>
                                <td>{$v.id}</td>
                                <td>{$v.username}</td>
                                <td>{$v.pass}</td>
                                <td>{$v.nickname}</td>
                                <td>{$v.phone}</td>
                                <td>{:date('Y-m-d',$v.regtime)}</td>
                                <td>
                                    {if $v.isvip == 0} 非vip
                                    {else} vip
                                    {/if}
                                </td>
                                <td>
                                    <a class='btn btn-primary btn-sm' href="{:url('admin/user/edit',['id'=>$v.id])}">编辑</a>
                                    <button class='btn btn-danger btn-sm del-btn' data-id="{$v.id}">删除</button>
                                </td>
                            </tr>
                        {/foreach}
                            
                        </tbody>
                    </table>
                    <ul class="pagination">
                            <li class='pageli'><a href="{:url('admin/user/index?page=1')}">&laquo;</a></li>
                            {for start="1" end="$count+1"}
                            <li class='pageli'><a href="{:url('admin/user/index')}?page={$i}">{$i}</a></li>
                            {/for}
<!--                             <li class='pageli'><a>2</a></li>
                            <li class='pageli'><a>3</a></li>
                             -->
                            <li class='pageli'><a href="{:url('admin/user/index')}?page={$count}">&raquo;</a></li>
                    </ul>
                </div>
            </div>
<!-- 主体结束-->
{/block}

        </div>
    </div>

<script src="/static/admin/js/jquery.min.js"></script>
<script src="/static/admin/js/bootstrap.min.js"></script>
{js href="/static/admin/js/toastr.min.js"}


    {block name="js"}
    <script>

    // 给当前选中的li添加标识
    $(".lis li:nth-child(1)").addClass('active');

    $(function(){
        // 删除操作
        $('.del-btn').click(function(){
            var id = $(this).attr('data-id');
            console.log(id);
            if(confirm('确定要删除该用户吗?')){
                var obj = $(this).parents('tr');
                delajax(id, obj);
            }
        })
    })


    // 删除函数
    function delajax(id, obj){
        $.ajax({
            type:'delete',
            url: '/admin/'+id,
            dataType:'json',
            success:function(data){
              if (data.status) {
                    toastr.success(data.info);
                    obj.remove();
                } else {
                    toastr.error(data.info,'FBI WARNING: ');
                }
            },
            error:function(){
                alert('ajax执行失败');
            }
        })
    }

    </script>
    {/block}
</body>
</html>
